package com.allwinter.yibangsafe.utils;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import org.springframework.beans.factory.annotation.Value;

public class TengxunCosUtils {

    @Value("${tengxun.secretId}")
    private String secretId;

    @Value("${tengxun.secretKey}")
    private String secretKey;

    @Value("${tengxun.region}")
    private String region;

    @Value("${tengxun.bucketName}")
    private String bucketName;

    @Value("${tengxun.url}")
    private String path;

    public COSClient initCOSClient(){
        COSCredentials cred = new BasicCOSCredentials(secretId,secretKey);
        Region region = new Region(this.region);
        ClientConfig clientConfig = new ClientConfig(region);
        //生成cos客户端
        COSClient cosClient = new COSClient(cred,clientConfig);
        return cosClient;
    }

}
